<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>订单详情</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>

		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-pull-left"></a>
			<h1 class="mui-title">订单详情</h1>
			<span class="mui-icon mui-icon-close mui-pull-right" onclick="window.history.go(-2);"></span>			
		</header>
		<div class="mui-content">
			<div style="background: white;width: 100%;height: 100px;padding-top: 10px;">
				<p style="margin-left: 10px;height: 30px;line-height: 30px;font-size: 24px;">交易金额(元)</p>
				<p style="margin-top: 20px;"><span style="margin-left: 10px;font-size: 30px;color: #007AFF;float: left;" id="money"></span><span style="float: right;margin-right: 10px;" id="orderStatus"></span></p>
			</div>
			<!--<div class="mui-input-group">-->
			<ul class="mui-table-view" style="margin-top: 20px;">
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">交易单号</label><label style="margin-left: 20px;color: #333;" id="orderNum"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">交易时间</label><label style="margin-left: 20px;color: #333;" id="orderDate"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">交易类型</label><label style="margin-left: 20px;color: #333;" id="accessName"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">手&nbsp;&nbsp;续&nbsp;&nbsp;费</label><label style="margin-left: 20px;color: #333;" id="rate"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">到账金额</label><label style="margin-left: 20px;color: #333;" id="moneys"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">到账时间</label><label style="margin-left: 20px;color: #333;" id="overDate"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">到账方式</label><label style="margin-left: 20px;color: #333;" id="cardNum"></label>
				</li>
				<li class="mui-table-view-cell" id="reDeposit" style="display: none">
					<label style="color: #ACACB4;">重提时间</label><label style="margin-left: 20px;color: #333;" id="reDepositDate"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">支付银行</label><label style="margin-left: 20px;color: #333;" id="payBankName"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">支付卡号</label><label style="margin-left: 20px;color: #333;" id="payCardNo"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">结算银行</label><label style="margin-left: 20px;color: #333;" id="cashBankName"></label>
				</li>
				<li class="mui-table-view-cell">
					<label style="color: #ACACB4;">结算卡号</label><label style="margin-left: 20px;color: #333;" id="cashCardNo"></label>
				</li>
			</ul>

			<ul class="mui-table-view" style="margin-top: 20px;">
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right" onclick="doubt()">
						<span style="color: #333;" class="doubt">对此订单有疑问</span>
					</a>
				</li>
			</ul>

			<button data-loading-text = "提交中" type="button" id="confirm-btn" class="mui-btn mui-btn-primary confirm-btn" style="display: none;width: 90%;height:40px;font-size: 16px;margin-left: 5%;margin-top: 20px;">发起提现</button>
		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/app.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript">
            mui.init({
                swipeBack: true //启用右滑关闭功能
            });
			mui.ready(function() {
				$.ajax({
					url: "/thmlfApi/avs/pay/getpayreocrdinfo"+"?_d="+Date.parse(new Date()),
					type: "POST",
					data: {
						orderId: getUrlParam('orderId')
					},
					success: function(r) {
						if(r.code == 200) {
						    var data = r.result;
							var status = '';
                            var color = '';
                            switch(data.status) {
                                case 1:
                                    //等付款
                                    status = '未付款';
                                    color = '#FF0000';
                                    break;
                                case 2:
                                    //取消
                                    color = '#CCFF33';
                                    status = '取消';
                                    break;
                                case 3:
                                    // 退款
                                    color = '#9999FF';
                                    status = '退款';
                                    break;
                                case 4:
                                    // 处理中
                                    color = '#00CC00';
                                    status = '处理中';
                                    break;
                                case 6:
                                    // 提现失败
                                    status = '提现失败';
                                    color = '#FF6600';
//                                    $('#confirm-btn').css('display','block');
                                    break;
                                case 7:
                                    status = '支付成功';
                                    color = '#00CC00';
                                    break;
                                case 8:
                                    status = '缴费成功';
                                    color = '#7c34cc';
                                    break;
                            }
							$('#money').text(r.result.amountTotal);
							$('#orderStatus').text(status).css('color',color);
							$('#orderNum').text(r.result.orderNum);
							$('#orderDate').text(r.result.createDate);
							$('#accessName').text(r.result.accessName);
							$('#rate').text(r.result.serviceCost);
							$('#moneys').text(r.result.realAmount);
							$('#overDate').text(r.result.finishDate);
							$('#cardNum').text(r.result.remark);
                            $('#payBankName').text(r.result.payBank);
                            $('#payCardNo').text(r.result.payCardNo);
                            $('#cashBankName').text(r.result.collecBank);
                            $('#cashCardNo').text(r.result.cashCardNo);
//							$('#orderstatus').css()
							console.log('re',r.result);
							if (r.result.isRedeposit == 1){
							    $('#reDeposit').css('display','block');
							    $('#reDepositDate').text(r.result.redepositDate);
							}
						} else
							mui.alert(r.message);
					},
					error: function(e) {
						mui.alert("获取详情失败");
					}

				})
			});
			mui(document.body).on('tap', '.confirm-btn', function() {
				var btn = mui(this);
                btn.button('loading');
				var data = {
					"payerId": sessionStorage.getItem("payerId"),
					"orderNum": $('#orderNum').text(),
					"amount": $('#money').text(),
					"summary": $('#cardNum').text()
				};
				$.ajax({
					url: '/thmlfApi/avs/pay/deposit'+"?_d="+Date.parse(new Date()),
					type: 'POST',
					data: JSON.stringify(data),
					dataType: 'JSON',
					contentType: "application/json",
					success: function(r) {
						btn.button('reset');
						if(r.code == 200) {
							window.location.reload();
						} else
							mui.alert(r.message);
					},
					error: function(e) {
						btn.button('reset');
						mui.alert("请求失败，请重试");
					}
				})
			})
			function doubt() {
                var orderNum = $('#orderNum').text();
                var amount = $('#money').text();
                var summary = $('#cardNum').text();
                window.location.href = 'doubt.html?orderNum='+orderNum+"&amount="+amount+"&summary="+summary;
            }
		</script>
	</body>

</html>